<%@page
	import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="dao.UserDAO"%>
<%@ page import="java.util.List"%>
<%@ page import="models.user.User"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ranking</title>
<style type="text/css">
body {
	background-image: url("Images/background.png");
	background-size: cover;
}
table, td, th {

    border: 1px solid green;
}

th {
	text-align: center;
    background-color: #0090ff;
    color: white;
}
td {
	text-align: center;
}
.pos{
	position : relative;
	top: 100px;
}
.topcorner{
    position:absolute;
    top:10px;
    right: 10px;
 }
</style>
</head>
<body>
<div class = "pos">
<div class="center">
	<table align ="center">
		<tr>
			<th>No.</th>
			<th>Username</th>
			<th>Wins</th>
			<th>Losses</th>
		</tr>
		<tr></tr>
		<%
			ApplicationContext context = new ClassPathXmlApplicationContext(
					"beans.xml");
			UserDAO userDao = (UserDAO) context.getBean("userDao");
			List<User> users = userDao.rankUsers();
			for (int i = 0; i < users.size(); i++) {
				User u = users.get(i);
				out.println("<tr><td><b>" + (i + 1) + "</b></td> "
						+ "<td><b>" + u.getUsername() + "</b></td>"
						+ "<td><b>" + u.getWins() + "</b></td>" 
						+ "<td><b>"+ u.getLosses() + "</b></td></tr>");
			}
		%>
	</table>
	<br>
	<FORM align = "center"><INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true" style="font-style: bold; width: 100px"></FORM>
	</div></div>
</body>
</html>